/**
 * @Author     :lanbery
 * @e-mail     : lanbery@gmail.com
 * @version    : V1.0
 * @createtime : 2011-12-2-下午12:26:36
 */
package com.lambor.example.action;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Component;

import com.lambor.example.biz.IExampleBiz;
import com.lambor.example.entity.Example;
import com.opensymphony.xwork2.ActionSupport;

/**
 * @about this class :
 * @author           ： lanbery
 * @e-mail           : lanbery@gmail.com
 * @version          : V1.0
 * @modifytime       : 2011-12-2-下午12:26:36
 * @filepath         : SSI-com.lambor.example.action//ExampleAction.java
 *
 */
@Component
public class ExampleAction extends ActionSupport {

	/**
	 * @notation: 
	 * @field: serialVersionUID-long
	 *
	 */
	private static final long serialVersionUID = -320233340976800992L;
	
	/**
	 * @notation: 
	 * @field: iExampleBiz-IExampleBiz<Example>
	 *
	 */
	@Inject
	private IExampleBiz<Example> iExampleBiz;
	
	private Example example;
	private List<Example> results = new ArrayList<Example>();

	/**
	 * @e-mail: lanbery@gmail.com
	 * @return the example
	 */
	public Example getExample() {
		return example;
	}

	/**
	 * @e-mail: lanbery@gmail.com
	 * @param example the example to set
	 */
	public void setExample(Example example) {
		this.example = example;
	}

	/**
	 * @e-mail: lanbery@gmail.com
	 * @return the results
	 */
	public List<Example> getResults() {
		return results;
	}
	
	/**
	 * @e-mail: lanbery@gmail.com
	 * @param results the results to set
	 */
	public void setResults(List<Example> results) {
		this.results = results;
	}

	/**
	 * 
	 * @method annotations: 
	 * @creator           :lanbery
	 * @createtime        : 2011-12-2-下午12:38:53 
	 * @return            :String
	 * ExampleAction.method()
	 *
	 */
	public String addExample()throws Exception{
		try{
			Example entity = new Example();
			results = iExampleBiz.queryList(entity);
			iExampleBiz.add(example);
			System.out.println("lanbery>>>>>>>>>>>>>>>>>");
			return SUCCESS;
		}catch(DataAccessException dae){
			this.addActionMessage("添加信息失败！");
			System.out.println("lanbery>ee>>>");
			return ERROR;
		}
	}

	public String queryList()throws Exception{
		Example entity = new Example();
		results = iExampleBiz.queryList(entity);
		for(int i=0;i<results.size();i++){
			entity = results.get(i);
			System.out.println(i+">>>>"+entity.toString());
		}
		return SUCCESS;
	}
	
	
}
